import Vue from 'vue';
import { Locale, Toast, Dialog } from 'vant';
import enUS from 'vant/lib/locale/lang/en-US';
import Hybrid from '@/components/uzone-hybrid';
import './components/uzone-flexible';
import App from './App';
import router from './routes';
import store from './store';
import Api from './api';
import filters from './libs/filters';
import detect from './libs/detect';
import storage from './libs/storage';
import i18n from './service/i18n';
import buryPoint from '@/config/buryPoint';
import mixinTracker from "@/service/mixin-tracker";

// 全局混入
Vue.mixin(mixinTracker)

Vue.use(Toast);
Vue.use(Dialog);

Locale.use('en-US', enUS);

// 全局挂载 filter
Object.keys(filters).forEach((key, index) => {
  Vue.filter(key, filters[key]);
});

// promise polyfill
require('es6-promise').polyfill();

Vue.prototype.$storage = storage;

// 挂载 Api, 在组件内可直接 this.$api 访问
Vue.use(Api);
Vue.use(buryPoint);

Vue.config.productionTip = false;

Vue.prototype.$os = detect.os;

// eslint-disable-next-line no-nested-ternary
Vue.prototype.$hybrid = new Hybrid(detect.os.android ? 'android' : (detect.os.ios ? 'ios' : 'web'));

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
});
